# tco/ip service

import socket


def main():
    server_socket = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
    server_socket.bind(('', 10086))
    server_socket.listen(128)
    while True:
        print('waiting for connecting...')
        client_socket, client_addr = server_socket.accept()
        print('connected one client: ', client_socket, client_addr)
        client_socket.send(b'hello nice to meet you.\n')
        while True:
            recv_data = client_socket.recv(1024)
            print(recv_data.decode('utf-8'))
            if '886' == recv_data.decode('utf-8'):
                client_socket.send(b'bye!')
                client_socket.close()
                break
            else:
                client_socket.send('you are right!'.encode('utf-8'))
    server_socket.close()


if __name__ == '__main__':
    main()
